//
//  SEOrderExamineDetailCheckItemCell.swift
//  SmartEyeForPatient
//
//  Created by qdsg on 2021/4/23.
//

import UIKit

protocol SEOrderExamineDetailCheckItemCellDelegate: NSObjectProtocol {
    func orderExamineDetailCheckItemCellCancelAction(model: SEExamineReserveCheckItem)
}

class SEOrderExamineDetailCheckItemCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    var checkItem = SEExamineReserveCheckItem()
    weak var delegate: SEOrderExamineDetailCheckItemCellDelegate?

    func update(with model: SEExamineReserveCheckItem) {
        self.checkItem = model
        checkItemValueLabel.text = model.checkItemValue
        checkItemFeeLabel.text = String.init(format: "%.2lf", model.checkFee)
        cancelBtn.isEnabled = model.canCancelDetail == 1
        cancelBtn.backgroundColor = model.canCancelDetail == 1 ? Asset.main.color : UIColor(hex: "#E7E7E7")
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    @IBOutlet weak var checkItemValueLabel: UILabel!
    @IBOutlet weak var checkItemFeeLabel: UILabel!

    @IBOutlet weak var stackBgView: UIView! {
        didSet {
            stackBgView.layer.cornerRadius = 4
            stackBgView.layer.borderWidth = 1
            stackBgView.layer.borderColor = Asset.border.color.cgColor
        }
    }
    @IBOutlet weak var cancelBtn: UIButton! {
        didSet {
            cancelBtn.layer.cornerRadius = cancelBtn.frame.size.height / 2.0
            cancelBtn.layer.masksToBounds = true
        }
    }
    @IBAction func cancelBtnAction(_ sender: Any) {
        delegate?.orderExamineDetailCheckItemCellCancelAction(model: checkItem)
    }
}
